﻿using Newtonsoft.Json;
using PmSoft.Caching;

namespace PmSoft
{
    public class EntityCache
    {
        public EntityCache() { }

        public EntityCache(bool enableCache, string typeHashID)
        {
            this.EnableCache = enableCache;
            this.TypeHashID = typeHashID;
        }

        /// <summary>
        /// 分区缓存版本字典
        /// </summary>
        [JsonProperty("AreaVersion")]
        public Dictionary<string, Dictionary<int, int>> AreaVersionDictionary { get; set; } = new Dictionary<string, Dictionary<int, int>>();
        /// <summary>
        /// 实体缓存版本字典
        /// </summary>
        [JsonProperty("EntityVersion")]
        public Dictionary<string, int> EntityVersionDictionary { get; set; } = new Dictionary<string, int>();
        /// <summary>
        /// 全局缓存版本
        /// </summary>
        [JsonProperty("GlobalVersion")]
        public int GlobalVersion { get; set; } = 0;

        /// <summary>
        /// 缓存过期类型 
        /// </summary>
        [JsonProperty("CachingExpirationType")]
        public CachingExpirationType CachingExpirationType { get; set; }

        /// <summary>
        /// 是否使用缓存
        /// </summary>
        [JsonProperty("EnableCache")]
        public bool EnableCache { get; set; }

        /// <summary>
        /// 缓存分区的属性
        /// </summary>
        [JsonProperty("PropertiesOfArea")]
        public IEnumerable<EntityPropertyInfo> PropertiesOfArea { get; set; }

        /// <summary>
        /// 实体正文缓存对应的属性名称（如果不需单独存储实体正文缓存，则不要设置该属性）
        /// </summary>
        [JsonProperty("PropertyNameOfBody")]
        public EntityPropertyInfo PropertyNameOfBody { get; set; }

        /// <summary>
        /// 完整名称md5-16 
        /// </summary>
        [JsonProperty("TypeHash")]
        public string TypeHashID { get; set; }
    }
}
